home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fritz: All Fritz
/
All Fritz.zip
/
All Fritz
/
FILES
/
PROGNG_C
/
DBTOOLC.LZH
/
SOURCE.ARC
/
DCTMAIN.H
< prev
next >
Wrap
C/C++ Source or Header
|
1987-04-12
|
10KB
|
305 lines
/* ----------------------------------------------------------------
NAME:
dctmain.h - main #include file for c tools
SYNOPSIS:
#include "dctmain.h"
DESCRIPTION:
Contains many global variables, defines, and typedefs
for use by all c tools.
NOTES:
c_catch.c ONLY should define the variable C_CTCH_MAIN!
AUTHOR: J. A. Bortz/J. T. Cooper
Copyright (C) 1985, J. T. Cooper & Co., ALL RIGHTS RESERVED
---------------------------------------------------------------- */
#ifdef AZTEC
#include "math.h"
double atof();
long atol();
#else
#include <dos.h>
#include <math.h>
#endif
#ifdef LC2 /* version 2.15 has no void type */
#define void int
#endif
#ifdef MS /* version 3.0 doesn't like pointers to void functions */
#define void int /* so we cheat */
#endif
#ifdef LATTICE
extern long sizmem();
#endif
#ifndef LATTICE /* only Lattice has sizmem for status */
#define dctalloc(a,b) calloc(a,b)
extern char *calloc();
#else
extern char *dctalloc(), *calloc();
#endif
char *db_GetParm();
#define GetFunc(a,b) db_GetParm(a, b, ' ')
#define GetNext(a,b) db_GetParm(a, b, ',')
#define GetString(a,b) db_GetParm(a, b, 'S')
unsigned Offset(), Segment();
/************************************************************************
Common "C" Defines
************************************************************************/
#define Local static
#define Register
#define SPACE ' '
#ifndef min
#define min(a,b) ((a)<=(b)?(a):(b))
#endif
/************************************************************************
Global Variables
************************************************************************/
/* ------------------------------------------------------------------------
The follow code sets up the global variables used to hold the two
machine-context stack frames. They are declared int if CT_CTCH_MAIN
is defined, or external otherwise.
The DS register is stored in an interrupt vector location because
when doing a FAR access, the DS register must be set correctly so it can
retrieve the address necessary to retrieve itself! By storing it in an
interrupt vector, we know its offset via the vecno, and its segment is
0000 by default. We define macros to make this transparent.
------------------------------------------------------------------------ */
#ifndef C_CTCH_MAIN
#define C_CT_EXTERN extern
#else
#define C_CT_EXTERN
#endif
C_CT_EXTERN int Res_Mem; /* amount of memory (in KB) to reserve */
C_CT_EXTERN long Prog_Size; /* approx size of this program in bytes */
C_CT_EXTERN
int Our_Ds; /* DataSeg of the Resident Library */
C_CT_EXTERN
int DB_SETFLAG, /* if ON (1), next call to dispatch will enable */
/* assignment and recollection of dbase memvars */
DB_VARTYPE, /* used to keep type of variable */
DB_VARVAL, /* used to return memory variables */
DB_bx,
DB_C_VAR, /* holds address of character variable contents */
DB_C_bx, /* keeps bx for character variable */
DB_D_VAR, /* holds address of date variable contents */
DB_D_bx, /* keeps bx for date variable */
DB_L_VAR, /* holds address of logical variable contents */
DB_L_bx, /* keeps bx for logical variables */
DB_N_VAR, /* holds address of numeric variable contents */
DB_N_bx, /* keeps bx for numeric variables */
DB_S_VAR, /* holds address for global status integer */
DB_S_bx, /* keeps bx for status variable */
DB_E_VAR, /* holds address for global error integer */
DB_E_bx; /* keeps bx for error variable */
#ifdef C_CTCH_MAIN
double DB_STATUS=0; /* actual status variable */
/* These variables are initialized, so that their segments are
* predictable from compiler to compiler, since they must be
* accessed from assembler functions
*/
/* This is the Stack Frame for the Application Program (dBASE) */
int
sf1_bx=0,
sf1_sp=0,
sf1_ss=0,
#define sf1_ds (peekw(BASE_INTERRUPT, 0))
sf1_es=0;
/* and this is the Stack Frame for the Resident Library (us) */
int
sf2_sp=0,
sf2_ss=0,
sf2_es=0;
char *errmsg[] =
{
"",
"Invalid Memory Type",
"No Such Function",
"That array is already in use",
"Too many array elements requested",
"No more arrays available",
"Insufficient memory",
"Invalid array name",
"Array offset is out of range",
"Attempt to free invalid block",
"That array is empty",
"Invalid calling syntax for this function",
"I/O Error"
};
int DB_ERROR = 0; /* actual error variable */
int DB_ERRFLG = 1; /* flag to report errors or not */
int DB_BELLFLG = 1; /* flag to ring bell during errors */
#else
extern int DB_ERROR; /* actual error variable */
extern int DB_ERRFLG; /* flag to report errors or not */
extern int DB_BELLFLG; /* flag to ring bell during errors */
extern int
sf1_bx,
sf1_sp,
sf1_ss,
#define sf1_ds (peekw(BASE_INTERRUPT, 0))
sf1_es;
extern int
sf2_sp,
sf2_ss,
sf2_es;
extern double DB_STATUS;
extern char **errmsg;
#endif
C_CT_EXTERN char *CFuncArgs; /* holds args from cfunc call */
C_CT_EXTERN int ArgCount;
#define MAXARGS 10
#define LONGARG 80
C_CT_EXTERN char ArgVal[MAXARGS][LONGARG];
#define MSG_INV_TYPE 1
#define MSG_NO_FUNC 2
#define MSG_IN_USE 3
#define MSG_TOO_MANY 4
#define MSG_NO_MORE 5
#define MSG_NO_SPACE 6
#define MSG_NO_ARRAY 7
#define MSG_OUT_OF_BOUNDS 8
#define MSG_BAD_BLK 9
#define MSG_EMPTY 10
#define INV_CALL 11 /* invalid calling syntax */
#define MSG_IO_ERROR 12
extern unsigned ci_initint(), ci_callfunc();
/************************************************************************
CATCHINT Defines
************************************************************************/
#define CNAMELEN 32 /* C identifiers can be 32 chars */
#define INTRPT1 69 /* Primary interrupt location */
#define INTRPT2 70 /* 2nd interrupt location for temp storage */
#define BASE_INTERRUPT (INTRPT2*4)
#define INT_MEM_RESERVE (1024*4) /* Memory reserved for internal use */
#define ALLOC_OVHD (1024+8) /* overhead for internal calloc()'s */
/* codes for return type */
#define CHARTYPE 0
#define INTTYPE 1
#define LONGTYPE 2
#define DOUBLETYPE 3
#define FLOATTYPE 4
/************************************************************************
Common Structure Definitions
************************************************************************/
/* ------------------------------------------------------------------------
Catchint Dispatch Table
Holds information necessary to invoke function based on its name
------------------------------------------------------------------------ */
struct ci_DT
{
char F_Name[CNAMELEN]; /* Name of C function */
void (*F_Ptr)(); /* Pointer to Function */
char F_Descr[72]; /* Description of function */
};
#ifdef AZTEC
/* ------------------------------------------------------------------------
8086 register definitions for Aztec compiler
** ------------------------------------------------------------------------ */
struct regs
{
int ax;
int bx;
int cx;
int dx;
int si;
int di;
int ds;
int es;
};
#endif
/************************************************************************
dBase Memory Variable Accessing Macros
************************************************************************/
#ifdef LATTICE
#define SetStatus(val) poke(DB_S_VAR, DB_S_bx, (char *)&val, 8)
#define SetSRet(val) poke(DB_S_VAR, DB_S_bx, (char *)&val, 8)
#define SetNRet(val) poke(DB_N_VAR, DB_N_bx, (char *)&val, 8)
#define SetCRet(val) poke(DB_C_VAR, DB_C_bx, val, strlen(val))
#define SetDRet(val) poke(DB_D_VAR, DB_D_bx, (char *)&val, 8)
#define SetLRet(val) poke(DB_L_VAR, DB_L_bx, (char *)&val, 1)
#define SetERet(val) poke(DB_E_VAR, DB_E_bx, (char *)&val, 8)
#endif /* LATTICE */
#ifdef AZTEC /* +AZTEC+ */
#define SetStatus(val) movblock(&val, Our_Ds, DB_S_bx, DB_S_VAR, 8)
#define SetSRet(val) movblock(&val, Our_Ds, DB_S_bx, DB_S_VAR, 8)
#define SetNRet(val) movblock(&val, Our_Ds, DB_N_bx, DB_N_VAR, 8)
#define SetCRet(val) movblock(val, Our_Ds, DB_C_bx, DB_C_VAR, strlen(val))
#define SetDRet(val) movblock(&val, Our_Ds,DB_D_bx, DB_D_VAR, 8)
#define SetLRet(val) movblock(&val, Our_Ds,DB_L_bx, DB_L_VAR, 1)
#define SetERet(val) movblock(&val, Our_Ds, DB_E_bx, DB_E_VAR, 8)
#endif /* AZTEC */
#ifdef MS
/* microsoft uses custom version of poke (in c_catch.c) */
#define SetStatus(val) poke(DB_S_VAR, DB_S_bx, &val, 8)
#define SetSRet(val) poke(DB_S_VAR, DB_S_bx, &val, 8)
#define SetNRet(val) poke(DB_N_VAR, DB_N_bx, &val, 8)
#define SetCRet(val) poke(DB_C_VAR, DB_C_bx, val, strlen(val))
#define SetDRet(val) poke(DB_D_VAR, DB_D_bx, &val, 8)
#define SetLRet(val) poke(DB_L_VAR, DB_L_bx, &val, 1)
#define SetERet(val) poke(DB_E_VAR, DB_E_bx, &val, 8)
#endif /* Microsoft */